#include<iostream>
#include<algorithm>
using namespace std;
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		char ch;
		int ans = 1;
		for (int i = 0; i < n; i++) {
			cin >> ch;
			ans = max(ans, ch - 'a' + 1);
		}
		cout << ans << endl;
	}
	return 0;
}